//
//  LFRefreshAutoStateFooter.m
//  AntMarket
//
//  Created by LF on 2017/3/28.
//  Copyright © 2017年 LF. All rights reserved.
//

#import "LFRefreshAutoStateFooter.h"

@interface LFRefreshAutoStateFooter()

//**  没有数据的view */
@property (nonatomic, strong) UIView *nomoreView;

//**  lineView */
@property (nonatomic, strong) UIView *lineViewLeft;
@property (nonatomic, strong) UIView *lineViewRight;

//**  没有数据的label */
@property (nonatomic, strong) UILabel *nomoreLabel;

@end

@implementation LFRefreshAutoStateFooter

- (void)prepare
{
    [super prepare];
    
//    self.mj_h = 50;
//    
//    UIView *view = [[UIView alloc] init];
//    self.nomoreView = view;
//    
//    UIView *lineView1 = [[UIView alloc] init];
//    UIView *lineView2 = [[UIView alloc] init];
//    lineView1.backgroundColor = [UIColor lf_borderColor];
//    lineView2.backgroundColor = [UIColor lf_borderColor];
//    self.lineViewLeft = lineView1;
//    self.lineViewRight = lineView2;
//    
//    UILabel *label = [[UILabel alloc] init];
//    self.nomoreLabel = label;
//    
//    [self addSubview:view];
//    [view addSubview:lineView1];
//    [view addSubview:lineView2];
//    [view addSubview:label];
}

- (void)placeSubviews
{
    [super placeSubviews];
    
//    [self.nomoreView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.equalTo(self);
//    }];
//    
//    [self.nomoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.centerY.equalTo(self);
//    }];
//    
//    [self.lineViewLeft mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.equalTo(self);
//        make.right.equalTo(self.nomoreLabel.mas_left).with.offset(-15);
//        make.width.equalTo(@50);
//    }];
//
//    [self.lineViewRight mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.equalTo(self);
//        make.left.equalTo(self.nomoreLabel.mas_right).with.offset(15);
//        make.width.equalTo(@50);
//    }];
}

#pragma mark 监听控件的刷新状态
- (void)setState:(MJRefreshState)state
{
    MJRefreshCheckState;
    
//    switch (state) {
//        case MJRefreshStateIdle:
//            self.nomoreLabel.text = @"点击或者上拉加载更多数据";
//            break;
//        case MJRefreshStatePulling:
//            self.nomoreLabel.text = @"松开加载更多数据";
//            break;
//        case MJRefreshStateRefreshing:
//            self.nomoreLabel.text = @"加载数据中..";
//            break;
//        case MJRefreshStateNoMoreData:
//            self.nomoreLabel.text = @"没有更多数据啦!!";
//        default:
//            break;
//    }
    NSString *nomoreDataText = @"——   我是有底线的!!   ——";
    NSMutableAttributedString * attr = [[NSMutableAttributedString alloc] initWithString:nomoreDataText];
    
    self.stateLabel.textColor = state == MJRefreshStateNoMoreData ?  [UIColor lf_colorWithHexString:@"#cccccc"] : [UIColor lightGrayColor];
    switch (state) {
        case MJRefreshStateNoMoreData:
//            self.stateLabel.text = @"——   没有更多数据啦!!   ——";
            [attr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0f] range:NSMakeRange(0, 2)];
            [attr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0f] range:NSMakeRange(nomoreDataText.length - 2, 2)];
            self.stateLabel.attributedText = attr;
            break;
        case MJRefreshStateIdle:
            self.stateLabel.text = @"点击或上拉加载更多";
            break;
        case MJRefreshStateRefreshing:
            self.stateLabel.text = @"加载中...";
            break;
        default:
            break;
    }
}

@end
